package LearnAlgorithm.a_eclipseHello;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @version: 1.0
 * @Author: wuqiu
 * @date: 2023-07-17 16:48
 * @description: LeetcodeLearnAlgorithm -> LearnAlgorithm.a_eclipseHello
 */
public class test4 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("5");
        list.add("4");
        list.add("3");
        list.add("2");
        list.add("1");
        System.out.println("remove before:" + list.size());
        list.remove(0);
        list.remove(1);
        System.out.println("remove after:" + list.size());
        list.add("6");
        System.out.println("add after:" + list.size());
        System.out.println("6 index:" + list.indexOf("6"));
        System.out.println("3 index:" + list.indexOf("3"));

        list.sort(new Comparator<String>() {
            @Override
            public int compare(String s, String other) {
                return Integer.parseInt(s) - Integer.parseInt(other);
            }
        });
        System.out.println("sort after:" + list.size());
        System.out.println("6 index:" + list.indexOf("6"));
        System.out.println("3 index:" + list.indexOf("3"));
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}
